#include <iostream>
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

ll dp[15][11][2];

void init() {
    for (int i = 0; i < 15; i++) {
        for (int j = 0; j < 11; j++) {
            for (int k = 0; k < 2; k++) {
                dp[i][j][k] = -1;
            }
        }
    }
}

ll dfs(ll num, int offset, int len, int pre, int free) {
    if (len == 0) {
        return 1;
    }
    if (dp[len][pre][free] != -1) {
        return dp[len][pre][free];
    }
    ll ans = 0;
    int cur = (int) num / offset % 10;//第一位
    //这一位选还是不选
    if (pre == 10) {//上一位没有选择
        if (free == 0) {
            //说明是开头
            //不选
            ans += dfs(num, offset / 10, len - 1, 10, 1);
            for (int i = 1; i < cur; i++) {
                ans += dfs(num, offset / 10, len - 1, i, 1);
            }
            //选了cur
            if (cur != 0) {
                ans += dfs(num, offset / 10, len - 1, cur, 0);
            }
        } else {
            //说明前面没选, 位数变少了, 可以1到9
            ans += dfs(num, offset / 10, len - 1, 10, 1);
            for (int i = 1; i <= 9; i++) {
                ans += dfs(num, offset / 10, len - 1, i, 1);
            }
        }
    } else {
        if (free == 1) {
            //必须要选了, 自由选择
            for (int i = 0; i <= 9; i++) {
                //与上一位相差至少为2
                if (i <= pre - 2 || i >= pre + 2) {
                    ans += dfs(num, offset / 10, len - 1, i, 1);
                }
            }
        } else {
            //限制选择
            for (int i = 0; i <= cur; i++) {
                if (i <= pre - 2 || i >= pre + 2) {
                    if (i == cur) {
                        ans += dfs(num, offset / 10, len - 1, cur, 0);
                    } else {
                        ans += dfs(num, offset / 10, len - 1, i, 1);
                    }
                }
            }
        }
    }

    dp[len][pre][free] = ans;
    return ans;
}

void solve() {
    int l, r;
    cin >> l >> r;
    int temp = (l - 1) / 10;
    int offset = 1;
    int len = 1;
    while (temp > 0) {
        len++;
        offset *= 10;
        temp /= 10;
    }
    init();
    ll res1 = dfs(l - 1, offset, len, 10, 0);
    temp = r / 10;
    offset = 1;
    len = 1;
    while (temp > 0) {
        len++;
        offset *= 10;
        temp /= 10;
    }
    init();
    ll res2 = dfs(r, offset, len, 10, 0);
    cout << res2 - res1 << "\n";
}

int main() {

    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    int t;
    t = 1;

    while (t--) {
        solve();
    }
    return 0;
}